<!doctype html>
<html>
<head>
    <title></title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="../res/css/weui.css"/>
    <link rel="stylesheet" href="../res/css/weuix.css"/>
    <link rel="stylesheet" href="../res/css/common.css"/>
    <script src="../res/js/zepto.min.js"></script>
    <script src="../res/js/zepto.weui.js"></script> 
    <script src="../res/js/common.js?v="></script>
</head>
<body>
<body ontouchstart>
<div class="fixed-top">
    <div class="weui-header weui-btn_primary"> 
        <!--<div class="weui-header-left"><a class="icon icon-109 f-white"></a></div>-->
        <div class="weui-header-title">用户登录</div>
        <div class="weui-header-right"></div>
    </div>
</div>
<div class="weui-cells weui-cells_form" style="margin-top:0px;">
    <div class="weui-flex">
        <div class="weui-flex__item">
            <div class="placeholder">
                <img src="../res/images/login_user.jpg" class="img-max" style="display:block; margin:0 auto;">
            </div>
        </div>
    </div>
    <div class="weui-cell weui-cell_select weui-cell_select-after" style="margin-top:50px;">
        <div class="weui-cell__hd">
            <label class="weui-label">登录类别</label>
        </div>
        <div class="weui-cell__bd">
            <select class="weui-select" id="ddl_user_type">
                <option value="1">用户</option>
                <option value="2">服务点</option>
                <!--<option value="3">医生</option>-->
                <option value="5">药店</option>
            </select>
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd">
            <label class="weui-label">登录帐号</label>
        </div>
        <div class="weui_cell_bd weui_cell_primary">
            <input class="weui-input" placeholder="请输入登录帐号" class="weui_input" required id="txt_phone" type="tel">
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd">
            <label class="weui-label">登录密码</label>
        </div>
        <div class="weui-cell__bd">
            <input class="weui-input" placeholder="请输入登录密码" class="weui_input" required id="txt_paw" type="password">
        </div>
    </div>
    <div class="weui-flex" style="padding:5px 10px 0 10px;"><a href="javascript:;" style="margin-left: 75%;" onclick="doForget()">忘记密码</a></div>
</div>
<div class="weui-btn-area">
    <a href="javascript:;" class="weui-btn weui-btn_primary" onclick="doLogin()">登&nbsp;&nbsp;录</a>
</div>
<div class="weui-btn-area">
    <a href="javascript:;" class="weui-btn weui-btn_primary" onclick="doReg()">注&nbsp;&nbsp;册</a>
</div>
<br />
<br />
<div class="weui-footer weui-footer_fixed-bottom">
    <p class="weui-footer__text">Copyright &copy; 2020 <a href="http://www.yixianmedical.com/" style="color:Gray;">一线医疗</a></p>
</div>
<script>
    var strUserType;
	var strUserName, strPassWord;
    function doLogin() {
        strUserName = $("#txt_phone").val().trim();
        strPassWord = $("#txt_paw").val().trim();
        strUserType = $('#ddl_user_type').val();
        if (isSpace(strUserName)) {
            msgInfo("手机号码不能为空！");
            return false;
        }
        if (isSpace(strPassWord)) {
            msgInfo("登录密码不能为空！");
            return false;
        }
        var paramJson = { "phone": strUserName, "paw": strPassWord, "hospital_id": 1, "user_type": strUserType, "rand": Math.random() };
        if (strUserType == '5') {
            paramJson = { "actName": "DoShopLogin", "uid": strUserName, "upwd": strPassWord, "rand": Math.random() };
            ajaxPost("/nethospnew/service/nethosp_action.ashx", paramJson, doLoginOk);
        }
        else {
            paramJson = { "phone": strUserName, "paw": strPassWord, "hospital_id": 1, "user_type": strUserType, "rand": Math.random() };
            ajaxPost("publicLogin_login_loginData", paramJson, doLoginOk);
        }
//        if (strUserType == '6') {
//            goPage('/netcflz_wx/user_list.htm?orgid=440004901&openid=' + strUserName);
//            return false;
//        }
        
        return false;
    }

    function doLoginOk(jsonInfo) {
        if (strUserType == '5') {
            if (jsonInfo.code == '1') {
                sessionStorage.setItem("u_group_no", jsonInfo.group_no); 		//药店编码
				sessionStorage.setItem("group_name", strUserName); 				//药店账号
                localStorage.setItem("u_group_name", jsonInfo.group_name); 		//药店名称
                goPage('shop/views/shop_index.html'); 							//跳转到药店首页
            }
            else
                msgInfo(jsonInfo.msg);
        }
        else {
            if (jsonInfo.code == '200') {
                var userJson = jsonInfo.data;
                if (userJson.zt == 2) {
                    setUserInfo(userJson);
                    setUserType('0');
                    goPage('inquiry_doctor.htm');
                    /* autoLogin($('#ddl_user_type').val(), userJson.user_id, ""); */
                }
                else
                    msgInfo(jsonInfo.info);
            }
            else
                msgInfo(jsonInfo.info);
        }
    }

    function autoLogin(strUserType, strUserId, strOrgId) {
        paramJson = { "actName": "DoAutoLogin", "utype": strUserType, "uid": strUserId, "orgid": strOrgId, "rand": Math.random() };
        ajaxPost("/nethospnew/service/nethosp_action.ashx", paramJson);
    }

    function doReg() {
        /* goPage('inquiry_user_reg.htm'); */
		goPage("inquiry_user_reg.htm")
    }
	function doForget() {
	    /* goPage('inquiry_user_reg.htm'); */
		goPage("inquiry_user_forget.htm")
	}
</script>
</body>
</html>